package com.telra.app.server;

import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.impl.Log4JLogger;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooKeeper;
import org.apache.zookeeper.data.Stat;

public class ZooKeeperService implements Watcher {

    private static final Log4JLogger log = (Log4JLogger) LogFactory.getFactory().getInstance(ZooKeeperService.class);

    public ZooKeeperService() {

        ZooKeeper zk;
        try {
            zk = new ZooKeeper("localhost:2181", 3000, this);
            Stat st = zk.exists("/test/server/pubFreq", this);
            if (st != null) {
                byte[] b = zk.getData("/test/server/pubFreq", this, st);
                log.info("pubFreq=" + new String(b));
            }

        } catch (Exception e1) {
            e1.printStackTrace();
        }
    }


    public void process(WatchedEvent event) {

    }
}
